import unittest
import time
from common.base import get_driver
from page.mylogin_page import MyLogin
from page.centrol_page import Centrol
from page.thegeneral1_page import General
from page.thegeneral2_page import General1

class AddGood(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        driver = get_driver() #没有创建类
        driver.get('http://localhost:8080/ecshop/admin/privilege.php?act=login')
        cls.c=Centrol(driver)
        cls.g = General(driver)
        cls.g1 = General1(driver)
        cls.m = MyLogin(driver)
        cls.m.theclose()
        cls.m.theclick()
        cls.m.username()
        cls.m.password()
        cls.m.login()
    def test(self):
        self.c.themain()
        self.g.goods_name()
        self.g.goods_name_style()
        # self.g.goods_sn()
        self.g.cat_id()
        self.g.brand_id()
        self.g.suppliers()
        self.g.shop_price()
        self.g.volume()
        self.c.themain1()
        self.g1.goods_weight()
        self.g1.goods_number()
        self.g1.warn_number()
        # self.g1.checkbox()
        self.g1.keywords()
        self.g1.goods_brief()
        self.g1.confirm()
        time.sleep(5)
        goods_name = self.c.themain2()
        self.assertEqual('四大皆空平板电脑', goods_name, msg='断言失败')

    @classmethod
    def tearDownClass(cls) -> None:
        # 关闭浏览器
        cls.g1.quit()

if __name__ == '__main__':
    unittest.main(verbosity=2)
